home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-20
/
rs0422.zip
/
ROSEZSW
/
CALSETUP.C
next >
Wrap
C/C++ Source or Header
|
1990-09-20
|
8KB
|
220 lines
/*
* Copyright 1988 by the Radio Amateur Telecommunications Society
* and Thomas A. Moulton, W2VY
*
* This software may only be modified, copied, distributed or
* executed for non-profit purposes by individuals operating
* systems in the Amateur Radio Service. Credit to the
* author(s) and to the Radio Amateur Telecommunications Society
* must be made in modules where RATS provided software is used,
* and in any announcements and documentation.
*
* As a non-profit, research and development organization, the
* Radio Amateur Telecommunications Society distributes software
* in both executable and source forms. This policy is in place
* to encourage the development and distribution of OSI-based,
* networking tools. In order to protect the interests of the
* Society and the authors, we have placed some conditions
* of use on the software. Other groups are encouraged
* to place the same or similar guidelines on
* software they produce.
*
* The Radio Amateur Telecommunications Society reserves the right
* to specify and alter the terms under which software provided by
* the Society may be used. This policy is consistent with the
* objective of uniform and consistent "Open Systems Interconnections."
*
* All acceptable Amateur Radio related uses of this software
* will be outlined in the "ROSE Implementer's Guide". Individuals
* or organizations wishing to add to, or modify the provisions of
* the guide to accommodate local or evolutionary requirements
* should document the proposed change(s) and forward them to the
* Society. If accepted, written notification will be provided by
* the Society to the submitting organization or individual(s).
* The Society will then issue a "ROSE Implementer's Guide Change
* Notice". Periodically, the Society will re-issue the "ROSE
* Implementer's Guide" and incorporate the text of the change
* notices. This procedure has been put in to place to ensure
* compatibility between systems and to ensure their "Openness"
* and interoperability.
*
* No part of this software may be used in other packages
* without prior authorization from the author or the Society.
* Software incorporating this module, all or in part, must be
* provided to the Society prior to distribution or use by
* anyone not directly involved in testing of the revised
* environment. Current releases of the combined software must
* be provided to the Society in both source and executable
* forms. Adequate documention to produce an executable module
* from the provided source must also be included.
*
* Non-Amateur Radio non-profit uses may be authorized on a case
* by case basis. Inquiries for such use may be made in writing
* to the Society. Non-commercial uses consistent with the
* general principles of Open Systems Interconnection Reference
* Model will be generally considered with favor.
*
* Commercial licensing of the software is also available based
* on normal commercial terms. Licensing inquiries should be
* directed to the Society. Commercial licensing of the standard
* software will be done in situations which materially benefit
* the Amateur Radio Packet Network. Additional licensing is
* reserved by the individual authors.
*
* The Radio Amateur Telecommunications Society provides this software
* on an "as is" basis. The Society assumes no liability for
* loss incurred through the use of this software. Amateur Radio
* use of this software implies non-commercial and voluntary
* development, deployment and use of this software in a "Amateur",
* non-commercial service. Commercial users are encouraged to
* inspect their copies of the source code. Source code modification
* licenses are available if a combined Object and Source Code
* license was not originally established.
*
* The Society may be contacted by writing or calling at:
*
* The Radio Amateur Telecommunications Society
* 206 North Vivyen Street.
* Bergenfield, New Jersey 07621
*
* Telephone: 201-387-8896
*
*/
/* This file has the generic call setup routines */
#include "data.h"
#include "buffer.h"
#include "ax25.h"
#include "ax25l2.h"
#include "l3struc.h"
#include "x25cause.h"
#include "l3calls.h"
#include "upfcn.h"
/* Call Request assumes to have a set of linked peers and wants to
be passed the one with out a parent, and we will try to
find a link to adopt it (sorry couldn't resist) */
extern int userport;
extern struct ax25_addr *L2_source, L2_destin[6];
extern unsigned char node_addr[16];
extern int maxfcn;
extern struct upfcn *spcfcn[];
int check_x121(), callcmp(), find_call(), find_route(), find_path();
struct axcb *linked_to(), *USER_CONN(), *NET_CONN();
call_request(vc)
register struct VCS *vc;
{
static unsigned int cause, uport;
static int i;
static unsigned char *altlist;
static struct VCS *vcx;
int internal_fcn();
cause=Congestion+120; /* Default to no memory */
kill(vc->timer); /* In case we were queued */
vc->lcn = 255; /* This call is Not active */
get_nsap(vc,&L2_destin[0]);
if ((check_x121(node_addr,vc->addr) != -1)) /* This node, Local call */ {
vc->alt = 254; /* Local Outbound Call */
if (internal_fcn(&L2_destin[0],vc)) /* The buck stops here! */ {
vc->P=P2;
vc->lcn = 0; /* Call is no longer pending */
set_p(vc,P4,0);
return;
}
i=find_call(&L2_destin[0]);
uport = userport;
if ((i >= 0) && (L3_MAXVC[i] == 0)) {
uport = L3PORT[i];
if (!vc->digi.call[0]) callcpy(&vc->digi, &L3DIGI[i]);
i= -1;
}
if (i<0) /* Not a Level 3 user */ {
vc_l2_pars(vc);
vcx=vc->peer;
l2_adr(vcx->addr,&L2_destin[2], &L2_destin[3]);
get_nsap(vcx,&L2_source);
if (linked_to(&L2_destin[0],&L2_source,&i)) {
cause = Number_Busy+72; /* Call Collision */
goto error;
}
vc->lcn=0; /* Level 2 User */
vc->P=P2;
if (! (vc->parent=USER_CONN(uport, vc))) goto error;
insert_lcn(vc); /* Queue call, no alternatives */
return;
}
else /* Local Level 3 Call */ {
if (i<16) /* A network node, illegal */ {
cause = Access_Barred+245;
goto error;
}
vc->rand=0; /* Leaving the network */
vc->addr[0]=vc->peer->addr[0]=0;
if (! linked_to(&L2_destin[0],&L3CALL[0],&vc->parent)) /* New Link */ {
if ((vc->parent=NET_CONN(i)) == NULL) goto error;
}
if (vc->parent->R == R1) set_p(vc,P2,0);
else /* Link is not ready, queue call in llcn */ {
/* vc->lcn=255; /* Level 3 call pending */
insert_lcn(vc); /* append call */
}
return;
}
} else /* Remote Level 3 call do routing */ {
i = find_route(&altlist, vc->addr);
if (i == -1) /* Modified address, re-route */ {
vc->alt = 255; /* Clear, Address changed */
queue(&vc->timer, call_request, 0, vc);
return;
} else
if (i == 0) /* No Path */ {
cause=Not_Obtainable;
goto error;
}
i = (altlist[0]>>4) & 0x0f;
if (!i) /* Internal ERROR */ {
cause=Not_Obtainable+119;
goto error;
}
/* vc->lcn = 255; */
vc->tx_queue = (struct datastr *)altlist;
if ((find_path(vc) == TRUE)) return;
if (vc->alt == 255) cause=Out_of_Order; /* No good routes */
/* else No memory */
}
error: /* Fall Through, error */
vc->peer->peer = NULL;
vc->parent = NULL;
set_p(vc->peer,P6, cause);
free(vc);
}
int
internal_fcn(stn,vc)
struct ax25_addr *stn;
struct VCS *vc;
{
register struct upfcn *spc;
static int i;
for (i=0;i<maxfcn;i++) /* Check for all internal functions */ {
spc = spcfcn[i];
if (callcmp(stn, &spc->dnam)) {
vc->RESET = spc->reset;
vc->CLEAR = spc->clear;
vc->SEND = spc->send;
vc->RECV = spc->recv;
vc->CONNECTED = spc->conn;
return 1;
}
}
return 0;
}